package com.qingke.hibernate.bean;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.CallbackException;
import org.hibernate.Session;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.classic.Lifecycle;

@Entity
@Table(name="course")
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
public class Course /*implements Lifecycle*/{
	@Id
	@Column(name="id")
	private int id;
	
	@Column(name="code")
	private String code;
	
	@Column(name="name")
	private String name;
	
	@Column(name="description")
	private String description;
	
	
	@OneToMany(mappedBy="courseType")
	private Set<CourseModel> courseModels;


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public String getCode() {
		return code;
	}


	public void setCode(String code) {
		this.code = code;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public String getDescription() {
		return description;
	}


	public void setDescription(String description) {
		this.description = description;
	}


	public Set<CourseModel> getCourseModels() {
		return courseModels;
	}


	public void setCourseModels(Set<CourseModel> courseModels) {
		this.courseModels = courseModels;
	}


	@Override
	public String toString() {
		return "Course [id=" + id + ", code=" + code + ", name=" + name + ", description=" + description + "]";
	}
//	
//	@Override
//	public boolean onSave(Session s) throws CallbackException {
//		System.out.println("calling onSave..."+new Date(System.currentTimeMillis()));
//		return false;
//	}
//	@Override
//	public boolean onUpdate(Session s) throws CallbackException {
//		System.out.println("calling onUpdate..."+new Date(System.currentTimeMillis()));
//		return false;
//	}
//	@Override
//	public boolean onDelete(Session s) throws CallbackException {
//		System.out.println("calling onDelete..."+new Date(System.currentTimeMillis()));
//		return false;
//	}
//	@Override
//	public void onLoad(Session s, Serializable id) {
//		System.out.println("calling onLoad..."+new Date(System.currentTimeMillis()));
//	}
}
